Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
graphql query filter an attribute by "array of values" or "all except one value"

I have a graphql query like the following one. As you can see, I have a variable defined activityCategory which is of type array of strings. That filter is populated by a multiselect dropdown on the UI which will have options like All, category1, category2 etc. So when All is selected we would send empty array [] to the filter which will return all the categories records. Or what ever were selected by the user for eg: [category1, category2], which then will return only the selected category records only.

gql`
  query searchActivities(
    $activityCategory: [String]
  ) {
    expert {
      engagement {
        getActivities(
          searchQuery: {
            activityCategory: $activityCategory
          }
        ) {
          activities {
            activityId
            activityCategory
            createdDate
            action
          }
        }
      }
    }
  }
`;

Now, we have added one more category to the categories enum let`s say category3 which wouldn't be part of the UI multiselect filter. Also, the behaviour should be like if the option All is selected, it means give all categories records except this newly added category3. And if user selects few categories from the dropdown it'll behave in the same way it used to, an array of user selected values would be sent in the filter and only those will be received.

In short, for the variable activityCategory from the above query, the value would be either activityCategory: {ne: "category3"} or activityCategory: ["category1", "category2"]. How does the above query change in this case? What type would I define for the query variable activityCategory instead of [String]?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda